package com.item.controller;


import com.item.domain.TabList;
import com.item.service.TabListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class TabListController {

    @Autowired
    TabListService tabListService;

    @PostMapping(value = "/tabList/{limit}/{page}")
    public List<TabList> TabList(
            @PathVariable(value = "limit", required = false) int limit,
            @PathVariable(value = "page", required = false) int page,
            @RequestBody(required = false) TabList tabList) {
        List<TabList> tabLists = tabListService.findAll(limit, page, tabList);


        return tabLists;
    }

    @PostMapping(value = "/tabList/add")
    public Integer TabListAdd(@RequestBody TabList tabList) {

        int i = tabListService.add(tabList);
        return i;
    }

    @PutMapping(value = "/tabList/update")
    public Integer tabListUpdate(@RequestBody TabList tabList) {

        int i = tabListService.update(tabList);
        return i;
    }

    @DeleteMapping(value = "/tabList/{id}")
    public Integer tabListDelete(@PathVariable(value = "id") int id) {

        int i = tabListService.delete(id);
        return i;
    }

}
